<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:	Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/applications/view.html.php
 ^ 
 * Description: HTML view of all applications 
 ^ 
 * History:		NONE
 ^ 
 */
 
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

class WRecruitViewApplications extends JView
{
	function display($tpl = null)
	{
		$model		= &$this->getModel();
		global $mainframe, $option;
		$option = 'com_wrecruit';
		
		$mainframe = &JFactory::getApplication();
	    $version = new JVersion;
	    $joomla = $version->getShortVersion();
			$jversion = substr($joomla,0,3);
		
		
	    $user	=& JFactory::getUser();
		$uid=$user->id;
		// get configurations
		$config = Array();
		$results =  $model->getConfig();	
		if ($results){ //not empty
			foreach ($results as $result){
				$config[$result->configname] = $result->configvalue;
			}
		}

		$layoutName = JRequest :: getVar('layout', '');
		if ($layoutName == ''){
				$layoutName = $_SESSION['cur_layout'];
                }
		$_SESSION['cur_layout']=$layoutName;
		if(($layoutName == 'controlpanel') || ($layoutName == 'featuredcompaniesqueue')  || ($layoutName == 'goldcompaniesqueue') ||  ($layoutName == 'featuredjobsqueue')  ||  ($layoutName == 'goldjobsqueue')
		 	||  ($layoutName == 'goldresumesqueue') ||  ($layoutName == 'featuredresumesqueue') || ($layoutName == 'companiesqueue') || ($layoutName == 'departmentqueue') || ($layoutName == 'jobqueue')
			|| ($layoutName == 'appqueue') || ($layoutName == 'updates')  || ($layoutName == 'fieldsordering')  || ($layoutName == 'loadaddressdata')
			|| ($layoutName == 'appliedresumes')|| ($layoutName == 'resumesearch') || ($layoutName == 'addtofeaturedjobs')|| ($layoutName == 'addtogoldresumes') || ($layoutName == 'addtofeaturedresumes') || ($layoutName == 'addtofeaturedcompanies')|| ($layoutName == 'wrecruitstats')|| ($layoutName == 'addtogoldcompanies')|| ($layoutName == 'addtogoldjobs')|| ($layoutName == 'jobsearch') || ($layoutName=='employerpaymenthistory')  || 
			($layoutName=='jobseekerpaymenthistory')|| ($layoutName == 'payment_report') || ($layoutName == 'info') )
			$layoutName =$layoutName; //do nothing
		elseif(( $layoutName == 'jobappliedresume')|| ($layoutName == 'view_company')|| ($layoutName == 'view_job') ||($layoutName == 'company_departments') ||  ($layoutName == 'job_searchresult') || 
			  ($layoutName == 'resume_searchresults')||($layoutName=='jobseekerpaymentdetails') || ($layoutName == 'userstate_companies') || ($layoutName == 'userstate_jobs') || ($layoutName == 'userstate_resumes') || ($layoutName == 'employerpaymentdetails')
			  || ( $layoutName == 'userstats') ||($layoutName == 'package_paymentreport') ){ // only cancel
			//JToolBarHelper :: cancel();
		}elseif(( $layoutName == 'conf')  || ( $layoutName == 'configurations')  ||($layoutName == 'emailtemplate')){
				//JToolBarHelper :: save();
		}elseif( $layoutName == 'users')  {
			//JToolBarHelper :: editListX();
		}else{
			//if($layoutName != 'empapps' )
			//		JToolBarHelper :: addNewX();
			

			//JToolBarHelper :: editListX();
			//JToolBarHelper :: deleteList();
        		//JToolBarHelper :: cancel();
		}
		JToolBarHelper :: spacer(10);
//		JToolBarHelper :: preferences("com_wrecruit",'400');

		jimport('joomla.html.pagination');
		$limit		= $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
		//$limit		= $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', 5, 'int' );
		$limitstart	= $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
		if (isset($_SESSION['js_cur_page'])) $cur_page = $_SESSION['js_cur_page']; else $cur_page = null;

		if($layoutName == 'controlpanel'){								//control panel
			JToolBarHelper :: title('WRecruit');
			$result =  $model->getAllCategories($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'resumesearch'){								//resume search
			JToolBarHelper :: title(JText::_('JS_RESUME_SEARCH'));
			$result =  $model->getResumeSearchOptions();	
			$this->assignRef('searchoptions', $result[0]);
			$this->assignRef('searchresumeconfig', $result[1]);
		}elseif($layoutName=='resume_searchresults'){
			JToolBarHelper:: title(JText::_('JS_RESUME_SEARCHRESULTS'));
			JToolBarHelper :: cancel();
			if (isset($_POST['isresumesearch'])){
				if ($_POST['isresumesearch'] == '1'){
					$_SESSION['resumesearch_title'] = $_POST['title'];
					$_SESSION['resumesearch_name'] = $_POST['name'];
					$_SESSION['resumesearch_nationality'] = $_POST['nationality'];
					$_SESSION['resumesearch_gender'] = $_POST['gender'];
					if (isset($_SESSION['resumesearch_iamavailable'])) $_SESSION['resumesearch_iamavailable'] = $_POST['iamavailable'];
					$_SESSION['resumesearch_jobcategory'] = $_POST['jobcategory'];
					$_SESSION['resumesearch_jobtype'] = $_POST['jobtype'];
					if(isset($_POST['jobsalaryrange']))
						$_SESSION['resumesearch_jobsalaryrange'] = $_POST['jobsalaryrange'];
					$_SESSION['resumesearch_heighestfinisheducation'] = $_POST['heighestfinisheducation'];
					$_SESSION['resumesearch_experience'] = $_POST['experience'];
					$_SESSION['resumesearch_currency'] = $_POST['currency'];
					
				}
			}
				$jobstatus='';
				$title = $_SESSION['resumesearch_title'];
				$name = $_SESSION['resumesearch_name'];
				$nationality = $_SESSION['resumesearch_nationality'];
				$gender = $_SESSION['resumesearch_gender'];
				$iamavailable = '';//$_SESSION['resumesearch_iamavailable'];
				$jobcategory = $_SESSION['resumesearch_jobcategory'];
				$jobtype = $_SESSION['resumesearch_jobtype'];
				$jobsalaryrange = $_SESSION['resumesearch_jobsalaryrange'];
				$education = $_SESSION['resumesearch_heighestfinisheducation'];
				$experience = $_SESSION['resumesearch_experience'];
				$currency = $_SESSION['resumesearch_currency'];
			$result =  $model->getResumeSearch($uid,$title,$name,$nationality,$gender,$iamavailable,$jobcategory,$jobtype,$jobstatus,$jobsalaryrange,$education
			, $experience,$limit,$limitstart,$currency);	
			$items = $result[0];
			$total = $result[1];
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('searchresumeconfig', $result[2]);
		
		}elseif($layoutName == 'jobsearch'){								//job search
			JToolBarHelper :: title(JText::_('JS_JOB_SEARCH'));
			$result =  $model->getSearchOptions();	
			$this->assignRef('searchoptions', $result[0]);
			$this->assignRef('searchjobconfig', $result[1]);
		}elseif($layoutName == 'job_searchresult'){								//job asearch results
			JToolBarHelper :: title(JText::_('JS_JOB_SEARCHREULTS'));
			JToolBarHelper :: cancel();
			if (isset($_POST['isjobsearch'])){
				if ($_POST['isjobsearch'] == '1'){
					$_SESSION['jobsearch_keyword'] = $_POST['keyword'];
					$_SESSION['jobsearch_jobcategory'] = $_POST['jobcategory'];
					$_SESSION['jobsearch_jobtype'] = $_POST['jobtype'];
					$_SESSION['jobsearch_jobstatus'] = $_POST['jobstatus'];
					if(isset($_POST['salaryrangefrom'])) $_SESSION['jobsearch_salaryrangefrom'] = $_POST['salaryrangefrom'];
					if(isset($_POST['salaryrangeto'])) $_SESSION['jobsearch_salaryrangeto'] = $_POST['salaryrangeto'];
					if(isset($_POST['salaryrangetype'])) $_SESSION['jobsearch_salaryrangetype'] = $_POST['salaryrangetype'];
					//$_SESSION['jobsearch_heighestfinisheducation'] = $_POST['heighestfinisheducation'];
					$_SESSION['jobsearch_shift'] = $_POST['shift'];
					//$_SESSION['jobsearch_experience'] = $_POST['experience'];
					$_SESSION['jobsearch_durration'] = $_POST['durration'];
					$_SESSION['jobsearch_startpublishing'] = $_POST['startpublishing'];
					$_SESSION['jobsearch_stoppublishing'] = isset($_POST['stoppublishing'])? $_POST['stoppublishing'] : '';
					$_SESSION['jobsearch_company'] = $_POST['company'];
					$_SESSION['jobsearch_country'] = isset($_POST['country'])?$_POST['country']:'';
					$_SESSION['jobsearch_state'] = isset($_POST['state'])?$_POST['state']:'';
					$_SESSION['jobsearch_county'] = isset($_POST['county'])?$_POST['county']:'';
					$_SESSION['jobsearch_city'] = $_POST['city'];
					if(isset($_POST['zipcode']))$_SESSION['jobsearch_zipcode'] = $_POST['zipcode'];
					$_SESSION['jobsearch_currency'] = isset($_POST['currency'])? $_POST['currency'] : '';                                        
				}
			}	
			$keyword = $_SESSION['jobsearch_keyword'];
			$jobcategory = $_SESSION['jobsearch_jobcategory'];
			$jobtype = $_SESSION['jobsearch_jobtype'];
			$jobstatus = $_SESSION['jobsearch_jobstatus'];
			$salaryrangefrom = $_SESSION['jobsearch_salaryrangefrom'];
			$salaryrangeto = $_SESSION['jobsearch_salaryrangeto'];
			$salaryrangetype = $_SESSION['jobsearch_salaryrangetype'];
			//$education = $_SESSION['jobsearch_heighestfinisheducation'];
			$shift = $_SESSION['jobsearch_shift'];
			//$experience = $_SESSION['jobsearch_experience'];
			$currency = $_SESSION['jobsearch_currency'] ;			
			$durration = $_SESSION['jobsearch_durration'];
			$startpublishing = $_SESSION['jobsearch_startpublishing'];
			$stoppublishing = $_SESSION['jobsearch_stoppublishing'];
			$company = $_SESSION['jobsearch_company'];
			$country = $_SESSION['jobsearch_country'];
			$state = $_SESSION['jobsearch_state'];
			$county = $_SESSION['jobsearch_county'];
			$city = $_SESSION['jobsearch_city'];
            if(isset($_SESSION['jobsearch_zipcode']))  $zipcode = $_SESSION['jobsearch_zipcode'];
			else $zipcode = '';
			$result =  $model->getJobSearch($keyword,$jobcategory,$jobtype,$jobstatus,$salaryrangefrom,$salaryrangeto,$salaryrangetype
			,$shift,  $durration, $startpublishing, $stoppublishing	
			,$company,$country,$state,$county,$city,$zipcode,$limit,$limitstart,$currency);	
			$items= $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('listjobconfig', $result[2]);
		}elseif($layoutName == 'view_job'){								//view job
			JToolBarHelper :: title(JText::_('JS_JOB_DETAILS'));
			JToolBarHelper :: cancel();
			$jobid = $_GET['oi'];
			$result =  $model->getJobbyIdForView($jobid);	
			$this->assignRef('job', $result[0]);
			$this->assignRef('fieldsordering', $result[3]);
		}elseif($layoutName == 'view_company'){								//job search
			JToolBarHelper :: title(JText::_('JS_COMPANY_DETAILS'));
			JToolBarHelper :: cancel();
			$companyid = $_GET['md'];
			$result =  $model->getCompanybyIdForView($companyid);	
			$this->assignRef('company', $result[0]);
			$this->assignRef('fieldsordering', $result[3]);
		}elseif($layoutName == 'categories'){								//categories
			JToolBarHelper :: title(JText::_('CATEGORIES'));
            JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
			JToolBarHelper :: cancel();
			JToolBarHelper :: deleteList(JText::_('JS_ARE_YOU_SURE'),'deletecategoryandsubcategory','Delete Cat & Sub-Cat');
			
			$result =  $model->getAllCategories($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'subcategories'){								//sub categories
                        $categoryid = JRequest :: getVar('cd', '');
                        $session = JFactory::getSession();
                        $session->set('sub_categoryid', $categoryid);
			$result =  $model->getSubCategories($categoryid,$limitstart, $limit);
                        JToolBarHelper :: title(JText::_('SUB_CATEGORIES').' ['.$result[0][0]->cat_title.']');
                        JToolBarHelper :: addNewX('editsubcategories');
			JToolBarHelper :: editListX('editsubcategories');
			JToolBarHelper :: deleteList(JText::_('JS_ARE_YOU_SURE'),'removesubcategory');
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'jobtypes'){								//job types
			JToolBarHelper :: title(JText::_('JS_JOB_TYPES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllJobTypes($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'ages'){								//job types
			JToolBarHelper :: title(JText::_('JS_JOB_AGES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllAges($limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'careerlevels'){								//job types
			JToolBarHelper :: title(JText::_('JS_JOB_CAREER_LEVELS'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllCareerLevels($limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'experience'){								//job types
			JToolBarHelper :: title(JText::_('JS_JOB_EXPERIENCE'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllExperience($limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'salaryrangetype'){								//job types
			JToolBarHelper :: title(JText::_('JS_SALARY_RANGE_TYPES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllSalaryRangeType($limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
                }elseif($layoutName== 'message_history'){
			JToolBarHelper :: title(JText::_('JS_MESSAGES_HISTORY'));
                        $jobid =  JRequest::getVar('bd');
                        $resumeid =  JRequest::getVar('rd');
			$result =  $model->getMessagesbyJobResume($uid,$jobid,$resumeid,$limit,$limitstart);
			$this->assignRef('messages', $result[0]);
			$this->assignRef('totalresults', $result[1]);
			$this->assignRef('summary',$result[3]);
			if ( $result[1] <= $limitstart ) $limitstart = 0;
			$this->assignRef('limit', $limit);
			$this->assignRef('limitstart', $limitstart);
			$this->assignRef('bd', $jobid);
			$pagination = new JPagination( $total, $limitstart, $limit );
        		JToolBarHelper :: cancel('cancelmessagehistory');
		}elseif($layoutName == 'jobstatus'){								//job status
			JToolBarHelper :: title(JText::_('JS_JOB_STATUS'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllJobStatus($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'shifts'){								//shifts
			JToolBarHelper :: title(JText::_('JS_SHIFTS'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllShifts($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'highesteducations'){								//highest educations
			JToolBarHelper :: title(JText::_('JS_HIGHEST_EDUCATIONS'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllHighestEducations($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'companies'){				//companies
			JToolBarHelper :: title(JText::_('JS_COMPANIES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			if ($cur_page != 'companies'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'companies';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchjobcategory = $mainframe->getUserStateFromRequest( $option.'searchjobcategory', 'searchjobcategory',	'',	'string' );
			$searchcountry = $mainframe->getUserStateFromRequest( $option.'searchcountry', 'searchcountry',	'',	'string' );

			$result =  $model->getAllCompanies($searchcompany, $searchjobcategory, $searchcountry, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'companiesqueue'){				//companies queue
			JToolBarHelper :: title(JText::_('JS_COMPANIES_QUEUE'));
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchjobcategory = $mainframe->getUserStateFromRequest( $option.'searchjobcategory', 'searchjobcategory',	'',	'string' );
			$searchcountry = $mainframe->getUserStateFromRequest( $option.'searchcountry', 'searchcountry',	'',	'string' );

			$result =  $model->getAllUnapprovedCompanies($searchcompany, $searchjobcategory, $searchcountry, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'folders'){				//folders
			JToolBarHelper :: title(JText::_('JS_FOLDERS'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			if ($cur_page != 'folders'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'folders';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$result =  $model->getAllFolders($uid,$limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'foldersqueue'){				//folders queue
			JToolBarHelper :: title(JText::_('JS_FOLDERS_QUEUE'));

			$result =  $model->getAllUnapprovedFolders( $limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			$this->assignRef('items', $items);
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'jobs'){								//jobs
			JToolBarHelper :: title(JText::_('JS_JOBS'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$form = 'com_wrecruit.jobs.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchcompany = $mainframe->getUserStateFromRequest( $form.'searchcompany', 'searchcompany',	'',	'string' );
			$searchjobcategory = $mainframe->getUserStateFromRequest( $form.'searchjobcategory', 'searchjobcategory',	'',	'string' );
			$searchjobtype = $mainframe->getUserStateFromRequest( $form.'searchjobtype', 'searchjobtype',	'',	'string' );
			$searchjobstatus = $mainframe->getUserStateFromRequest( $form.'searchjobstatus', 'searchjobstatus',	'',	'string' );
			$result =  $model->getAllJobs($searchtitle, $searchcompany, $searchjobcategory, $searchjobtype, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'jobqueue'){										// job queue
			JToolBarHelper :: title(JText::_('JS_JOBS_APPROVAL_QUEUE'));
			$form = 'com_wrecruit.jobqueue.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchcompany = $mainframe->getUserStateFromRequest( $form.'searchcompany', 'searchcompany',	'',	'string' );
			$searchjobcategory = $mainframe->getUserStateFromRequest( $form.'searchjobcategory', 'searchjobcategory',	'',	'string' );
			$searchjobtype = $mainframe->getUserStateFromRequest( $form.'searchjobtype', 'searchjobtype',	'',	'string' );
			$searchjobstatus = $mainframe->getUserStateFromRequest( $form.'searchjobstatus', 'searchjobstatus',	'',	'string' );
			$result =  $model->getAllUnapprovedJobs($searchtitle, $searchcompany, $searchjobcategory, $searchjobtype, $searchjobstatus, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'appliedresumes'){								//applied resumes
			JToolBarHelper :: title(JText::_('JS_APPLIED_RESUME'));
			$form = 'com_wrecruit.appliedresumes.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchcompany = $mainframe->getUserStateFromRequest( $form.'searchcompany', 'searchcompany',	'',	'string' );
			$searchjobcategory = $mainframe->getUserStateFromRequest( $form.'searchjobcategory', 'searchjobcategory',	'',	'string' );
			$searchjobtype = $mainframe->getUserStateFromRequest( $form.'searchjobtype', 'searchjobtype',	'',	'string' );
			$searchjobstatus = $mainframe->getUserStateFromRequest( $form.'searchjobstatus', 'searchjobstatus',	'',	'string' );
			$result =  $model->getAppliedResume($searchtitle, $searchcompany, $searchjobcategory, $searchjobtype, $searchjobstatus, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'jobappliedresume'){								//job applied resume
			JToolBarHelper :: title(JText::_('JS_APPLIED_RESUME'));
			JToolBarHelper :: cancel();
			//$jobid = $_GET['oi'];
			$jobid = JRequest::getVar( 'oi');
			$form = 'com_wrecruit.jobappliedresume.list.';
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchjobtype = $mainframe->getUserStateFromRequest( $form.'searchjobtype', 'searchjobtype',	'',	'string' );
			$result =  $model->getJobAppliedResume($jobid, $searchname, $searchjobtype, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
			$this->assignRef('oi', $jobid);
		}elseif($layoutName == 'folder_resumes'){								//job applied resume
			JToolBarHelper :: title(JText::_('JS_FOLDER_RESUME'));
			//$jobid = $_GET['oi'];
			$folderid = JRequest::getVar( 'fd');
			$form = 'com_wrecruit.jobappliedresume.list.';
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchjobtype = $mainframe->getUserStateFromRequest( $form.'searchjobtype', 'searchjobtype',	'',	'string' );
			$result =  $model->getFolderResume($folderid, $searchname, $searchjobtype, $limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
			$this->assignRef('fd', $folderid);
			JToolBarHelper :: cancel();
		}elseif($layoutName == 'shortlistcandidates'){								//short list candidates
			JToolBarHelper :: title(JText::_('JS_SHORT_LIST_CANDIDATES'));
			$jobid = JRequest::getVar( 'oi');
			$form = 'com_wrecruit.jobappliedresume.list.';
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchjobtype = $mainframe->getUserStateFromRequest( $form.'searchjobtype', 'searchjobtype',	'',	'string' );
			$result =  $model->getJobAppliedResume($jobid, $searchname, $searchjobtype, $limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
			$this->assignRef('oi', $jobid);
		}elseif($layoutName == 'empapps'){								//employment applications
			JToolBarHelper :: title(JText::_('JS_RESUME'));
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$form = 'com_wrecruit.empapps.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchjobcategory = $mainframe->getUserStateFromRequest( $form.'searchjobcategory', 'searchjobcategory',	'',	'string' );
			$searchjobtype = $mainframe->getUserStateFromRequest( $form.'searchjobtype', 'searchjobtype',	'',	'string' );
			$searchjobsalaryrange = $mainframe->getUserStateFromRequest( $form.'searchjobsalaryrange', 'searchjobsalaryrange',	'',	'string' );
			$result =  $model->getAllEmpApps($searchtitle, $searchname, $searchjobcategory, $searchjobtype, $searchjobsalaryrange, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'appqueue'){		//app queue
			JToolBarHelper :: title(JText::_('JS_RESUME_APPROVAL_QUEUE'));
			$form = 'com_wrecruit.appqueue.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchjobcategory = $mainframe->getUserStateFromRequest( $form.'searchjobcategory', 'searchjobcategory',	'',	'string' );
			$searchjobtype = $mainframe->getUserStateFromRequest( $form.'searchjobtype', 'searchjobtype',	'',	'string' );
			$searchjobsalaryrange = $mainframe->getUserStateFromRequest( $form.'searchjobsalaryrange', 'searchjobsalaryrange',	'',	'string' );
			$result =  $model->getAllUnapprovedEmpApps($searchtitle, $searchname, $searchjobcategory, $searchjobtype, $searchjobsalaryrange, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'salaryrange'){									// salary range
			JToolBarHelper :: title(JText::_('JS_SALARY_RANGE'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllSalaryRange($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'updates'){										// roles
			JToolBarHelper :: title(JText::_('JS_ACTIVATE_UPDATES'));
			$configur =  $model->getConfigur();	
			$this->assignRef('configur', $configur);
		}elseif($layoutName == 'roles'){										// roles
			JToolBarHelper :: title(JText::_('JS_ROLES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			$result =  $model->getAllRoles($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'users'){										// users
			JToolBarHelper :: title(JText::_('USERS'));
			JToolBarHelper :: editListX();
			$form = 'com_wrecruit.users.list.';
			$searchname	= $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname','', 'string' );
			$searchusername	= $mainframe->getUserStateFromRequest( $form.'searchusername', 'searchusername','', 'string' );
			$searchcompany	= $mainframe->getUserStateFromRequest( $form.'searchcompany', 'searchcompany','', 'string' );
			$searchresume	= $mainframe->getUserStateFromRequest( $form.'searchresume', 'searchresume','', 'string' );
			$searchrole	= $mainframe->getUserStateFromRequest( $form.'searchrole', 'searchrole','', 'string' );
			$result =  $model->getAllUsers($searchname,$searchusername,$searchcompany,$searchresume,$searchrole, $limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'userstats'){										// users
			JToolBarHelper :: title(JText::_('JS_USER_STATS'));
			JToolBarHelper :: cancel();
			$form = 'com_wrecruit.users.list.';
			$searchname	= $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname','', 'string' );
			$searchusername	= $mainframe->getUserStateFromRequest( $form.'searchusername', 'searchusername','', 'string' );
			$result =  $model->getUserStats($searchname,$searchusername, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'userstate_companies'){										// users
			JToolBarHelper :: title(JText::_('JS_USER_STATS_COMPANIES'));
			JToolBarHelper :: cancel();
			$companyuid=JRequest::getVar('md');
			$result =  $model->getUserStatsCompanies($companyuid,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$this->assignRef('companyuid', $companyuid);
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'userstate_jobs'){										// users
			JToolBarHelper :: title(JText::_('JS_USER_STATS_JOBS'));
			JToolBarHelper :: cancel();
			$jobuid=JRequest::getVar('bd');
			$result =  $model->getUserStatsJobs($jobuid,$limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('jobuid', $jobuid);
		}elseif($layoutName == 'userstate_resumes'){										// users
			JToolBarHelper :: title(JText::_('JS_USER_STATS_RESUMES'));
			JToolBarHelper :: cancel();
			$resumeuid=JRequest::getVar('ruid');
			$result =  $model->getUserStatsResumes($resumeuid,$limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('resumeuid', $resumeuid);
		}elseif($layoutName == 'wrecruitstats'){										// users
			JToolBarHelper :: title(JText::_('JS_JOBS_STATS'));
			$result =  $model->getWRecruitStats();	
			$this->assignRef('companies', $result[0]);
			$this->assignRef('jobs', $result[1]);
			$this->assignRef('resumes', $result[2]);
			$this->assignRef('featuredcompanies', $result[3]);
			$this->assignRef('goldcompanies', $result[4]);
			$this->assignRef('featuredjobs', $result[5]);
			$this->assignRef('goldjobs', $result[6]);
			$this->assignRef('featuredresumes', $result[7]);
			$this->assignRef('goldresumes', $result[8]);
			$this->assignRef('totalpaidamount', $result[9]);
		}elseif($layoutName == 'userfields'){										// user field
			JToolBarHelper :: title(JText::_('JS_USER_FIELDS'));
			JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
        		JToolBarHelper :: cancel();
			//$searchname	= $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname','', 'string' );
			$fieldfor = JRequest::getVar('ff');
			if ($fieldfor) $_SESSION['ffusr'] = $fieldfor; else $fieldfor = $_SESSION['ffusr'];
			$result =  $model->getUserFields($fieldfor, $limitstart, $limit);	// 1 for company
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'configurations'){
			JToolBarHelper :: title(JText::_('JS_CONFIGURATIONS'));
                        JToolBarHelper :: save();
			$result =  $model->getConfigurationsForForm();	
			$this->assignRef('lists', $result[1]);
		}elseif($layoutName == 'info'){
			JToolBarHelper :: title(JText::_('Information'));
		}elseif($layoutName == 'conf'){											// configurations
			JToolBarHelper :: title(JText::_('CONFIG'));
                        JToolBarHelper :: save();
			$result =  $model->getConfigurationsForForm();	
			$this->assignRef('lists', $result[1]);
		}elseif($layoutName == 'fieldsordering'){										// field ordering
			JToolBarHelper :: title(JText::_('JS_FIELDS'));
                        //$fieldfor = $_GET['ff'];
		$fieldfor = JRequest::getVar('ff',0);
                        $session = JFactory::getSession();
                        $session->set('fieldfor',$fieldfor);
                        $fieldfor= $session->get('fieldfor');


			if ($fieldfor) $_SESSION['fford'] = $fieldfor; else $fieldfor = $_SESSION['fford'];
			$result =  $model->getFieldsOrdering($fieldfor, $limitstart, $limit);	// 1 for company
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'emailtemplate'){										// email template
			$templatefor = $_GET['tf'];
			switch($templatefor){
				case 'ew-cm' : $text = JText::_('JS_NEW_COMPANY'); break;
				case 'cm-ap' : $text = JText::_('JS_COMPANY_APPROVAL'); break;
				case 'cm-rj' : $text = JText::_('JS_COMPANY_REJECTING'); break;
				case 'ew-ob' : $text = JText::_('JS_NEW_JOB'); break;
				case 'ob-ap' : $text = JText::_('JS_JOB_APPROVAL'); break;
				case 'ob-rj' : $text = JText::_('JS_JOB_REJECTING'); break;
				case 'ew-rm' : $text = JText::_('JS_NEW_RESUME'); break;
				case 'ew-ms' : $text = JText::_('JS_NEW_MESSAGE'); break;
				case 'rm-ap' : $text = JText::_('JS_RESUME_APPROVAL'); break;
				case 'rm-rj' : $text = JText::_('JS_RESUME_REJECTING'); break;
				case 'ba-ja' : $text = JText::_('JS_JOB_APPLY'); break;
				case 'ew-md' : $text = JText::_('JS_NEW_DEPARTMENT'); break;
				case 'ew-rp' : $text = JText::_('JS_EMPLOYER_BUY_PACKAGE'); break;
				case 'ew-js' : $text = JText::_('JS_JOBSEEKER_BUY_PACKAGE'); break;
				case 'ms-sy' : $text = JText::_('JS_MESSAGE'); break;
				case 'jb-at' : $text = JText::_('JS_JOB_ALERT'); break;
			}
			JToolBarHelper :: title(JText::_('JS_EMAIL_TEMPLATES').' <small><small>['.$text.'] </small></small>');
                        JToolBarHelper :: save();
			$template =  $model->getTemplate($templatefor);	
			$this->assignRef('template', $template);
		}elseif($layoutName == 'countries'){										// countries
			JToolBarHelper :: title(JText::_('JS_COUNTRIES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: deleteList();
			if ($cur_page != 'countries'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'countries';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$result =  $model->getAllCountries($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'states'){										// states
			$countrycode = $_GET['ct'];
			$_SESSION['js_countrycode'] = $countrycode;
			JToolBarHelper :: title(JText::_('JS_STATES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: deleteList();
			if ($cur_page != 'states'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'states';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$result =  $model->getAllCountryStates($countrycode, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'counties'){										// counties
			$statecode = $_GET['sd'];
			$_SESSION['js_statecode'] = $statecode;
			JToolBarHelper :: title(JText::_('JS_COUNTIES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: deleteList();
			if ($cur_page != 'counties'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'counties';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$result =  $model->getAllStateCounties($statecode, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'cities'){										// cities
			$countycode = $_GET['co'];
			$_SESSION['js_countycode'] = $countycode;
			JToolBarHelper :: title(JText::_('JS_CITIES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: deleteList();
			if ($cur_page != 'cities'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'cities';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$result =  $model->getAllCountyCities($countycode, $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'loadaddressdata'){										// load address data
			JToolBarHelper :: title(JText::_('JS_LOAD_ADDRESS_DATA'));
			$error = 0;
			if (isset($_GET['er'])) $error = $_GET['er'];
			$this->assignRef('error', $error);
		}elseif($layoutName == 'goldresumes'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_GOLD_RESUMES'));
			$form = 'com_wrecruit.empapps.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchjobseekerpackage = $mainframe->getUserStateFromRequest( $form.'searchjobseekerpackage', 'searchjobseekerpackage',	'',	'string' );
			$result =  $model->getGoldResumes($searchtitle,$searchname,$searchjobseekerpackage,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists',$lists);
			JToolBarHelper :: addNewX();
		}elseif($layoutName == 'goldresumesqueue'){				//companies queue
			JToolBarHelper :: title(JText::_('JS_GOLD_RESUMES_QUEUE'));
			$form = 'com_wrecruit.empapps.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchjobseekerpackage = $mainframe->getUserStateFromRequest( $form.'searchjobseekerpackage', 'searchjobseekerpackage',	'',	'string' );
			$result =  $model->getAllUnapprovedGoldResume($searchtitle,$searchname,$searchjobseekerpackage,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists',$lists);
		}elseif($layoutName == 'addtogoldresumes'){								//employment applications
			JToolBarHelper :: title(JText::_('JS_ADD_TO_GOLD_RESUMES'));
			$result =  $model->getAllEmpAppsListing($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'featuredresumes'){								//featured resume 
			JToolBarHelper :: title(JText::_('JS_FEATURED_RESUMES'));
			$form = 'com_wrecruit.empapps.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $form.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$result =  $model->getFeaturedResumes($searchtitle,$searchname,$searchemployerpackage,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists',$lists);
			JToolBarHelper :: addNewX();
		}elseif($layoutName == 'featuredresumesqueue'){				//featuredresumequeue
			JToolBarHelper :: title(JText::_('JS_FEATURED_RESUMES_QUEUE'));
			$form = 'com_wrecruit.empapps.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchname = $mainframe->getUserStateFromRequest( $form.'searchname', 'searchname',	'',	'string' );
			$searchjobseekerpackage = $mainframe->getUserStateFromRequest( $form.'searchjobseekerpackage', 'searchjobseekerpackage',	'',	'string' );
			$result =  $model->getAllUnapprovedFeaturedResume($searchtitle,$searchname,$searchjobseekerpackage,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists',$lists);
		}elseif($layoutName == 'addtofeaturedresumes'){								//employment applications
			JToolBarHelper :: title(JText::_('JS_ADD_TO_FEATURED_RESUMES'));
			$result =  $model->getAllEmpAppsListing( $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'featuredjobs'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_FEATURED_JOBS'));
			$form = 'com_wrecruit.jobs.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchcompany = $mainframe->getUserStateFromRequest( $form.'searchcompany', 'searchcompany',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $form.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$result =  $model->getFeaturedJobs($searchtitle,$searchcompany,$searchemployerpackage,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists' , $lists);
			JToolBarHelper :: addNewX();
		}elseif($layoutName == 'featuredjobsqueue'){				//companies queue
			JToolBarHelper :: title(JText::_('JS_FEATURED_JOBS_QUEUE'));
			$form = 'com_wrecruit.jobs.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchcompany = $mainframe->getUserStateFromRequest( $form.'searchcompany', 'searchcompany',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $form.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$result =  $model->getAllUnapprovedFeaturedJobs($searchtitle,$searchcompany,$searchemployerpackage,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists' , $lists);
		}elseif($layoutName == 'goldjobs'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_GOLD_JOBS'));
			$form = 'com_wrecruit.jobs.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchcompany = $mainframe->getUserStateFromRequest( $form.'searchcompany', 'searchcompany',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $form.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$result =  $model->getGoldJobs($searchtitle,$searchcompany,$searchemployerpackage,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists' , $lists);
			JToolBarHelper :: addNewX();
		}elseif($layoutName == 'addtogoldjobs'){								//jobs
			JToolBarHelper :: title(JText::_('JS_ADD_TO_GOLD_JOBS'));
			$result =  $model->getAllJobListings($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'addtofeaturedjobs'){								//jobs
			JToolBarHelper :: title(JText::_('JS_ADD_TO_FEATURED_JOBS'));
			$result =  $model->getAllJobListings($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'goldjobsqueue'){				//companies queue
			JToolBarHelper :: title(JText::_('JS_GOLD_JOBS_QUEUE'));
			$form = 'com_wrecruit.jobs.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchcompany = $mainframe->getUserStateFromRequest( $form.'searchcompany', 'searchcompany',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $form.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$result =  $model->getAllUnapprovedGoldJobs($searchtitle,$searchcompany,$searchemployerpackage,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists' , $lists);
		}elseif($layoutName == 'departments'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_DEPARTMENTS'));
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchdepartment = $mainframe->getUserStateFromRequest( $option.'searchdepartment', 'searchdepartment',	'',	'string' );
			$result =  $model->getDepartments($searchcompany,$searchdepartment,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'company_departments'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_COMPANY_DEPARTMENTS'));
			JToolBarHelper :: cancel();
			$companyid = $_GET['md'];
			$_SESSION['companyid'] = $companyid;
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchdepartment = $mainframe->getUserStateFromRequest( $option.'searchdepartment', 'searchdepartment',	'',	'string' );
			$result =  $model->getCompanyDepartments($companyid,$searchcompany,$searchdepartment,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if(isset($result[2])) $lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			 if(isset($lists))  $this->assignRef('lists', $lists);
			$this->assignRef('companyid', $companyid);
		}
		elseif($layoutName == 'departmentqueue'){				//companies queue
			JToolBarHelper :: title(JText::_('JS_DEPARTMENT_QUEUE'));
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchdepartment = $mainframe->getUserStateFromRequest( $option.'searchdepartment', 'searchdepartment',	'',	'string' );
			//$searchcountry = $mainframe->getUserStateFromRequest( $option.'searchcountry', 'searchcountry',	'',	'string' );
			$result =  $model->getAllUnapprovedDepartments($searchcompany,$searchdepartment,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'goldcompanies'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_GOLD_COMPANIES'));
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $option.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$searchcountry = $mainframe->getUserStateFromRequest( $option.'searchcountry', 'searchcountry',	'',	'string' );

			$result =  $model->getGoldCompanies($searchcompany,$searchemployerpackage,$searchcountry,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];

			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
			JToolBarHelper :: addNewX();
		}elseif($layoutName == 'goldcompaniesqueue'){				//companies queue
			JToolBarHelper :: title(JText::_('JS_GOLD_COMPANIES_QUEUE'));
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $option.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$searchcountry = $mainframe->getUserStateFromRequest( $option.'searchcountry', 'searchcountry',	'',	'string' );
			$result =  $model->getAllUnapprovedGoldCompanies($searchcompany,$searchemployerpackage,$searchcountry,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'addtogoldcompanies'){				//companies
			JToolBarHelper :: title(JText::_('JS_ADD_TO_GOLD_COMPANIES'));
			$result =  $model->getAllCompaniesListing( $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'featuredcompanies'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_FEATURED_COMPANIES'));
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $option.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$searchcountry = $mainframe->getUserStateFromRequest( $option.'searchcountry', 'searchcountry',	'',	'string' );
			$result =  $model->getFeaturedCompanies($searchcompany,$searchemployerpackage,$searchcountry,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
			JToolBarHelper :: addNewX();
		}elseif($layoutName == 'featuredcompaniesqueue'){				//companies queue
			JToolBarHelper :: title(JText::_('JS_FETAURED_COMPANIES_QUEUE'));
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchemployerpackage = $mainframe->getUserStateFromRequest( $option.'searchemployerpackage', 'searchemployerpackage',	'',	'string' );
			$searchcountry = $mainframe->getUserStateFromRequest( $option.'searchcountry', 'searchcountry',	'',	'string' );
			$result =  $model->getAllUnapprovedFeaturedCompanies($searchcompany,$searchemployerpackage,$searchcountry,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'addtofeaturedcompanies'){				//companies
			JToolBarHelper :: title(JText::_('JS_ADD_TO_FEATURED_COMPANIES'));
			$result =  $model->getAllCompaniesListing( $limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'employerpaymenthistory'){								
			JToolBarHelper :: title(JText::_('JS_EMPLOYER_PAYMENT_HISTORY'));
			$form = 'com_wrecruit.jobs.list.';
			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchprice = $mainframe->getUserStateFromRequest( $form.'searchprice', 'searchprice',	'',	'string' );
			$searchpaymentstatus = $mainframe->getUserStateFromRequest( $form.'searchpaymentstatus', 'searchpaymentstatus',	'',	'string' );

			$result =  $model->getEmployerPaymentHistory($searchtitle,$searchprice,$searchpaymentstatus,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			$this->assignRef('lists', $lists);
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'payment_report'){								
			JToolBarHelper :: title(JText::_('JS_PAYMENT_REPORT'));
			$form = 'com_wrecruit.jobs.list.';
			$buyername = $mainframe->getUserStateFromRequest( $form.'buyername', 'buyername',	'',	'string' );
			$paymentfor = $mainframe->getUserStateFromRequest( $form.'paymentfor', 'paymentfor',	'',	'string' );
			$searchpaymentstatus = $mainframe->getUserStateFromRequest( $form.'searchpaymentstatus', 'searchpaymentstatus',	'',	'string' );
			$searchstartdate = $mainframe->getUserStateFromRequest( $form.'prsearchstartdate', 'prsearchstartdate',	'',	'string' );
			$searchenddate = $mainframe->getUserStateFromRequest( $form.'prsearchenddate', 'prsearchenddate',	'',	'string' );
			$result =  $model->getPaymentReport($buyername,$paymentfor,$searchpaymentstatus,$searchstartdate,$searchenddate,$limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			$this->assignRef('lists', $lists);
			$this->assignRef('paymentfor', $result[3]);
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'package_paymentreport'){								
			$packageid=JRequest::getVar('pk');
			if ($packageid) $_SESSION['pk'] = $packageid; else $packageid = $_SESSION['pk'];
			$paymentfor=JRequest::getVar('pf');
			if ($paymentfor) $_SESSION['pf'] = $paymentfor; else $paymentfor = $_SESSION['pf'];
			//$packageid=JRequest::getVar('pk');
			//$paymentfor=JRequest::getVar('pf');
			$form = 'com_wrecruit.jobs.list.';
			$searchpaymentstatus = $mainframe->getUserStateFromRequest( $form.'searchpaymentstatus', 'searchpaymentstatus',	'',	'string' );

			$searchstartdate = $mainframe->getUserStateFromRequest( $form.'searchstartdate', 'searchstartdate',	'',	'string' );
			$searchenddate = $mainframe->getUserStateFromRequest( $form.'searchenddate', 'searchenddate',	'',	'string' );
			$result =  $model->getPackagePaymentReport($packageid,$paymentfor,$searchpaymentstatus,$searchstartdate,$searchenddate,$limitstart, $limit);	
			JToolBarHelper :: title($result[0][0]->packagetitle.' '.JText::_('JS_REPORT'));
			JToolBarHelper :: cancel();
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			$this->assignRef('lists', $lists);
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'jobseekerpaymenthistory'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_JOBSEEKER_PAYMENT_HISTORY'));
			$form = 'com_wrecruit.jobs.list.';

			$searchtitle = $mainframe->getUserStateFromRequest( $form.'searchtitle', 'searchtitle',	'',	'string' );
			$searchprice = $mainframe->getUserStateFromRequest( $form.'searchprice', 'searchprice',	'',	'string' );
			$searchpaymentstatus = $mainframe->getUserStateFromRequest( $form.'searchpaymentstatus', 'searchpaymentstatus',	'',	'string' );
			$result =  $model->getJobseekerPaymentHistory($searchtitle,$searchprice,$searchpaymentstatus,$limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			$this->assignRef('lists', $lists);
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'employerpaymentdetails'){										// employer package info
			JToolBarHelper :: cancel();
			$paymentid = $_GET['pk'];
			$_SESSION['js_paymentid'] = $paymentid;
			JToolBarHelper :: title(JText::_('JS_PAYMENT_HISTORY_DETAILS'));
			//if ($cur_page != 'states'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'states';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$result =  $model->getEmployerPaymentHistorybyId($paymentid);
			$items = $result[0];
		}elseif($layoutName == 'jobseekerpaymentdetails'){										// employer package info
			$packageid = $_GET['pk'];
			$_SESSION['js_packageid'] = $packageid;
			JToolBarHelper :: title(JText::_('JS_PAYMENT_HISTORY_DETAILS'));
			JToolBarHelper :: cancel();
			//if ($cur_page != 'states'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'states';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$result =  $model->getJobseekerPaymentHistorybyId($packageid);	
			$items = $result[0];
		}elseif($layoutName == 'employerpackages'){								//employer packages
			JToolBarHelper :: title(JText::_('JS_EMPLOYER_PACKAGES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
			$result =  $model->getEmployerPackages($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
		}elseif($layoutName == 'jobseekerpackages'){								//job seeker packages
			JToolBarHelper :: title(JText::_('JS_JOBSEEKER_PACKAGES'));
                        JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();
			$result =  $model->getJobSeekerPackages($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
	}elseif($layoutName == 'currency'){

			JToolBarHelper :: title(JText::_('JS_CURRENCY'));
            JToolBarHelper :: addNewX();
			JToolBarHelper :: editListX();
			JToolBarHelper :: deleteList();

			$result =  $model->getAllCurrencies($limitstart, $limit);	
			$items = $result[0];
			$total = $result[1];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			
	}elseif(($layoutName == 'messages') || ($layoutName == 'messagesqueue')){				//messages
			if($layoutName == 'messages'){
                            $statusoperator = "<>";
                            JToolBarHelper :: title(JText::_('JS_MESSAGES'));
                            JToolBarHelper :: editListX();
                            JToolBarHelper :: deleteList();
                        }else{
                            $statusoperator = "=";
                            JToolBarHelper :: title(JText::_('JS_MESSAGES_APPROVAL_QUEUE'));
                        }
			if ($cur_page != 'messages'){	$limitstart = 0;	$_SESSION['js_cur_page'] = 'messages';	$mainframe->setUserState( $option.'.limitstart', $limitstart );	}
			$username = $mainframe->getUserStateFromRequest( $option.'message_username', 'message_username',	'',	'string' );
			$usertype = $mainframe->getUserStateFromRequest( $option.'message_usertype', 'message_usertype',	'',	'string' );
			$conflict= $mainframe->getUserStateFromRequest( $option.'message_conflicted', 'message_conflicted',	'',	'string' );
			$company = $mainframe->getUserStateFromRequest( $option.'message_company', 'message_company',	'',	'string' );
			$jobtitle = $mainframe->getUserStateFromRequest( $option.'message_jobtitle', 'message_jobtitle',	'',	'string' );
			$subject = $mainframe->getUserStateFromRequest( $option.'message_subject', 'message_subject',	'',	'string' );
			$result =  $model->getAllMessages($statusoperator,$username, $usertype, $company, $jobtitle, $subject, $limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}elseif($layoutName == 'companiesqueue'){				//companies queue
			JToolBarHelper :: title(JText::_('JS_COMPANIES_QUEUE'));
			$searchcompany = $mainframe->getUserStateFromRequest( $option.'searchcompany', 'searchcompany',	'',	'string' );
			$searchjobcategory = $mainframe->getUserStateFromRequest( $option.'searchjobcategory', 'searchjobcategory',	'',	'string' );
			$searchcountry = $mainframe->getUserStateFromRequest( $option.'searchcountry', 'searchcountry',	'',	'string' );
			$result =  $model->getAllUnapprovedCompanies($searchcompany, $searchjobcategory, $searchcountry, $limitstart, $limit);
			$items = $result[0];
			$total = $result[1];
			$lists = $result[2];
			if ( $total <= $limitstart ) $limitstart = 0;
			$pagination = new JPagination( $total, $limitstart, $limit );
			$this->assignRef('lists', $lists);
		}else{
			JToolBarHelper :: title(JText::_('JS_JOBS'));
		}
		$this->assignRef('items', $items);
		$this->assignRef('config', $config);
		$this->assignRef('option', $option);
		$this->assignRef('pagination', $pagination);
		parent :: display($tpl);
	}
}
?>
